#include <iostream>
using namespace std;
void selectionsort(int* a,int n){
	for (int i=0;i<(n-1);i++){
		cout << "Luot. lap. thu' i = :" << i <<endl;
		int min = i;
		for(int j=i+1;j<n;j++){
			if(a[j] < a[min]){
				min = j;
			}
		}
		if(min != i){
			int tam = a[i];
			a[i] = a[min];
			a[min] = tam;
		}
		for (int i = 0;i<n;i++){
			cout << a[i] << "\t";
		}
		cout << endl;
	}
}
int main(){
	int *a = new int[8];
	a[0] = 12;
	a[1] = 5;
	a[2] = 3;
	a[3] = 10;
	a[4] = 18;
	a[5] = 4;
	a[6] = 9;
	a[7] = 16;
	cout << "Mang dau vao la a:\n";
	for (int i=0;i<8;i++){
		cout << a[i] << "\t";
	}
	cout << endl;
	selectionsort(a,8);
}
